home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Softshoe / Lisa's Mac Parts / Files / Volumes / VolumeInfo.h < prev    next >
Text File  |  2000-06-23  |  4KB  |  106 lines

  1. // VolumeInfo.h
  2.  
  3. #ifndef VolumeInfo_h
  4. #define VolumeInfo_h
  5.  
  6. #ifndef Str_h
  7. #include "Str.h"
  8. #endif
  9. #ifndef Volume_h
  10. #include "Volume.h"
  11. #endif
  12. #ifndef AllocationBlock_h
  13. #include "AllocationBlock.h"
  14. #endif
  15. #ifndef Drive_h
  16. #include "Drive.h"
  17. #endif
  18. #ifndef Driver_h
  19. #include "Driver.h"
  20. #endif
  21. #ifndef FileSystem_h
  22. #include "FileSystem.h"
  23. #endif
  24.  
  25. #include <Devices.h>
  26.  
  27. class VolumeInfo: public HParamBlockRec
  28.   {
  29.     private:
  30.         String31 name;
  31.         
  32.         void ThrowError( OSErr );
  33.  
  34.         bool Attribute( uint16 bit ) const                                { return ( volumeParam.ioVAtrb & bit ) != 0; }
  35.     
  36.     public:
  37.         VolumeInfo();
  38.         VolumeInfo( ConstPString );
  39.         VolumeInfo( ::Volume );
  40.         VolumeInfo( uint16 index );
  41.         
  42.         VolumeInfo( const VolumeInfo& );
  43.         void operator==( const VolumeInfo& );
  44.         
  45.         void Get();
  46.         void Get( ConstPString );
  47.         void Get( ::Volume );
  48.         void Get( uint16 index );
  49.         
  50.         bool TryToGet( uint16 index );                                    // returns false if the index is too large
  51.         
  52.         void Set();
  53.         void Set( ::Volume );
  54.         
  55.         ConstPString Name() const                                            { return name; }
  56.         ::Volume Volume() const                                                { return ::Volume( volumeParam.ioVRefNum ); }
  57.         
  58.         uint32 CreationTime() const                                        { return volumeParam.ioVCrDate; }
  59.         uint32 ModificationTime() const                                    { return volumeParam.ioVLsMod; }
  60.         uint32 BackupTime() const                                            { return volumeParam.ioVBkUp; }
  61.         
  62.         bool Busy() const                                                        { return Attribute( 0x0040 ); }
  63.         bool Locked() const                                                    { return Attribute( 0x8080 ); }
  64.         bool LockedByHardware()    const                                        { return Attribute( 0x0080 ); }
  65.         bool LockedBySoftware() const                                        { return Attribute( 0x8000 ); }
  66.         
  67.         AllocationBlock FirstBitmapBlock() const                        { return AllocationBlock( volumeParam.ioVBitMap ); }
  68.         AllocationBlock NextAllocation() const                            { return AllocationBlock( volumeParam.ioAllocPtr ); }
  69.         AllocationBlock FirstBlockMapBlock() const                    { return AllocationBlock( volumeParam.ioAlBlSt ); }
  70.  
  71.         uint16 AllocationBlockCount() const                                { return volumeParam.ioVNmAlBlks; }
  72.         uint32 AllocationBlockSize() const                                { return volumeParam.ioVAlBlkSiz; }
  73.         uint32 ClumpSize() const                                            { return volumeParam.ioVClpSiz; }
  74.         
  75.         uint32 NextCatalogNode() const                                    { return volumeParam.ioVNxtCNID; }
  76.         
  77.         uint16 FreeAlloocationBlocks() const                            { return volumeParam.ioVFrBlk; }
  78.         
  79.         uint16 Signature() const                                            { return volumeParam.ioVSigWord; }
  80.         
  81.         bool Online() const                                                    { return volumeParam.ioVDrvInfo != 0; }
  82.         bool Offline() const                                                    { return volumeParam.ioVDrvInfo == 0; }
  83.         bool Ejected() const                                                    { return Offline() && volumeParam.ioVDRefNum > 0; }
  84.  
  85.         ::Drive Drive() const;
  86.         ::Driver Driver() const;
  87.                 
  88.         ::FileSystem FileSystem() const                                    { return ::FileSystem( volumeParam.ioVFSID ); }
  89.  
  90.         uint16 FilesInRoot() const                                            { return volumeParam.ioVNmFls; }
  91.         uint32 FileCount() const                                            { return volumeParam.ioVFilCnt; }
  92.         uint32 DirectoryCount() const                                        { return volumeParam.ioVDirCnt; }
  93.  
  94.         uint32 WriteCount() const                                            { return volumeParam.ioVWrCnt; }
  95.         
  96.         void SetName( ConstPString newName )                            { name = newName; }
  97.         void SetCreationTime( uint32 time )                                { volumeParam.ioVCrDate = time; }
  98.         void SetModificationTime( uint32 time )                        { volumeParam.ioVLsMod = time; }
  99.         void SetBackupTime( uint32 time )                                { volumeParam.ioVBkUp = time; }
  100.         
  101.         void Lock()                                                                { volumeParam.ioVAtrb |= int16(0x8000); }
  102.         void Unlock()                                                            { volumeParam.ioVAtrb &= int16(~0x8000); }
  103.   };
  104.  
  105. #endif
  106.